package com.swanclouds.redfish.account.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.model.account.Account;

import java.util.Map;

/**
 * @author 张立强
 *
 */
public class AccountModel implements Account {

    @JsonProperty("Description")
    private String description;

    @JsonProperty("UserName")
    private String userName;

    @JsonProperty("RoleId")
    private String roleId;

    @JsonProperty("Enabled")
    private Boolean enabled;

    @JsonProperty("Locked")
    private Boolean locked;

    @JsonProperty("Oem")
    private Map<String,Object> oem;

    /**
     * 用户描述
     *
     * @return description
     */
    @Override
    public String getDescription() {
        return this.description;
    }

    /**
     * 账户用户名
     *
     * @return userName
     */
    @Override
    public String getUserName() {
        return this.userName;
    }

    /**
     * 角色
     *
     * @return roleId
     */
    @Override
    public String getRoleId() {
        return this.roleId;
    }

    /**
     * 用户是否使能
     *
     * @return enabled
     */
    @Override
    public Boolean getEnabled() {
        return this.enabled;
    }

    /**
     * 帐户服务是否被自动锁定
     *
     * @return locked
     */
    @Override
    public Boolean getLocked() {
        return this.locked;
    }

    /**
     * 自定义属性
     *
     * @return oem
     */
    @Override
    public Map<String, Object> getOem() {
        return this.oem;
    }

    @JsonProperty("@odata.id")
    private String dataId;

    @JsonProperty("@odata.context")
    private String context;

    @JsonProperty("@odata.type")
    private String type;

    @JsonProperty("Id")
    private String id;

    @JsonProperty("Name")
    private String name;

    /**
     * 系统资源的访问路径
     *
     * @return dataId
     */
    @Override
    public String getDataId() {
        return this.dataId;
    }

    /**
     * 系统资源模型的OData描述信息
     *
     * @return context
     */
    @Override
    public String getContext() {
        return this.context;
    }

    /**
     * 系统资源的类型
     *
     * @return type
     */
    @Override
    public String getType() {
        return this.type;
    }

    /**
     * 系统资源的ID
     *
     * @return Id
     */
    @Override
    public String getId() {
        return this.id;
    }

    /**
     * 系统资源的名称
     *
     * @return Name
     */
    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "AccountModel {" +
                "description='" + description + '\'' +
                ", userName='" + userName + '\'' +
                ", roleId='" + roleId + '\'' +
                ", enabled=" + enabled +
                ", locked=" + locked +
                ", oem=" + oem +
                ", dataId='" + dataId + '\'' +
                ", context='" + context + '\'' +
                ", type='" + type + '\'' +
                ", id='" + id + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
